<template>
  <div>
    注册

    <van-form @submit="onSubmit">
        <van-cell-group inset>
          <van-field
            v-model="userName"
            name="userName"
            label="用户名"
            placeholder="用户名"
            :rules="[{ required: true, message: '请填写用户名' }]"
          />
           <van-field
            v-model="userPwd"
            name="userPwd"
            label="密码"
            placeholder="密码"
            :rules="[{ required: true, message: '请填写密码' }]"
          />
           <van-field
            v-model="phone"
            name="phone"
            label="手机号"
            placeholder="手机号"
            :rules="[{ required: true, message: '请填写手机号' }]"
          />
          <van-field
            v-model="email"
            name="email"
            label="邮箱"
            placeholder="邮箱"
            :rules="[{ required: true, message: '请填写邮箱' }]"
          />
        </van-cell-group>
        <div style="margin: 16px;">
          <van-button round block type="primary" native-type="submit">
            注册
          </van-button>
        </div>
      </van-form>
  </div>
</template>

<script setup>
    import {ref,reactive} from 'vue'
    import {regStudentApi} from '../../api/login.js'
     import {showSuccessToast} from 'vant'
    let userName=ref('')
    let userPwd=ref('')
    let phone=ref('')
    let email=ref('')
    // 表单的提交事件
    let onSubmit=async (values)=>{
        console.log(values)
        values.nickname=''
        values.userPic=''
      let res=await regStudentApi(values)
      console.log(res,"-------")
      if(res.data.success){
        showSuccessToast('注册成功');
      }
      userName.value=''
      userPwd.value=''
      phone.value=''
      email.value=''
    }

</script>
